package net.onest.praticaltrainning;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener {
    private BottomNavigationView navigationView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nav_bottom);
        navigationView = findViewById(R.id.nav_bottom);
        navigationView.setOnNavigationItemSelectedListener(this);
        navigationView.setSelectedItemId(R.id.menu_one);
    }

    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        switch (item.getItemId()){
            case R.id.menu_one:
                fragmentTransaction.replace(R.id.home_fragment, new fragment_one()).commit();
                return true;
            case R.id.menu_two:
                fragmentTransaction.replace(R.id.home_fragment,new fragment_two()).commit();
                return true;
            case R.id.menu_three:
                fragmentTransaction.replace(R.id.home_fragment,new fragment_three()).commit();
                return true;
        }
        return true;
    }
}